'''
直接对获得到的features进行拟合，不再调度生成模型的文件
'''

import pandas as pd
from sklearn import svm
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
import os

def excute_the_features():
    try:
        train_data = pd.read_csv(os.getcwd()+'\script\orgin_datas.csv')  # 训练数据路径
        # train_data = pd.read_csv('orgin_datas.csv')

        # 划分特征和标签
        X_train = train_data.drop('label', axis=1)
        y_train = train_data['label']

        # 训练SVM模型
        model = svm.SVC(kernel='linear', C=1.0)
        model.fit(X_train, y_train)

        test_data = pd.read_csv("datas.csv") # 测试数据路径
        # test_data = pd.read_csv(os.getcwd().replace("script","datas.csv"))

        # 标准化测试数据
        # X_test_scaled = scaler.transform(test_data.columns.values)

        # 待预测的数据（注意：这里的数据应该是二维的，即使只有一个样本）
        # to_predict = [[0,2,8,5,27,0,0,8,16,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,11,3,4,0,4,11,16,12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,11,14,10,0,1,11,4,19,0,4,8,17,10,0,0,12,8,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1]]

        # to_predict = [features.columns.values]

        # 预测
        predictions = model.predict([test_data.columns.values])
        # predictions = model.predict()
        print(predictions)

    except Exception as e:
        print(e)

if __name__ == '__main__':
    excute_the_features()